package showhow.simple.common.enums;

public enum CustomerLevel {
    LEVEL_1(1, 1.0F, "等级1"),
    LEVEL_2(2, 0.9F, "等级2"),
    LEVEL_3(3, 0.8F, "等级3"),
    LEVEL_4(4, 0.7F, "等级4"),
    LEVEL_5(5, 0.6F, "等级5");

    private final int code;
    /** 折扣 */
    private final float discount;
    private final String msg;

    CustomerLevel(int code, float discount, String msg) {
        this.code = code;
        this.discount = discount;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public float getDiscount() {
        return discount;
    }

    public String getMsg() {
        return msg;
    }

    public static CustomerLevel get(Integer code){
        for(CustomerLevel deviceTypeEnum : CustomerLevel.values()){
            if(code.equals(deviceTypeEnum.getCode())){
                return deviceTypeEnum;
            }
        }
        return LEVEL_1;
    }
}
